﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DBSourceToolsLib.CodeParser
{
    public abstract class ChainNode : IChain
    {
        //private bool m_bHasLink;
        //protected ChainNode m_Chain;
        //public ChainNode()
        //{
        //    m_bHasLink = false;
        //}

        //public abstract void sendToChain(List<ParseObject> lstParseObjects, List<IResolved> lstResolved);

        //public void addToChain(ChainNode oChain)
        //{
        //    m_Chain = oChain;
        //    m_bHasLink = true;
        //}
        //public ChainNode getChain()
        //{
        //    return m_Chain;
        //}
        //public bool hasChain() { return m_bHasLink; }

        //protected void sendChain(List<ParseObject> lstParseObjects, List<IResolved> lstResolved)
        //{ // send the message on down the chain
        //    if (m_Chain != null)
        //        m_Chain.sendToChain(lstParseObjects, lstResolved);
        //}

        private ChainNode nextChain;
        protected List<ParseObject> lstParseObjects;
        private bool hasChain;

        public ChainNode()
        {
            lstParseObjects = new List<ParseObject>();
            hasChain = false;
        }

        public void addToChain(ChainNode c)
        {
            nextChain = c;
            hasChain = true;
        }

        public abstract bool interpret();

        public void sendtoChain(List<ParseObject> olstParseObjects)
        {
            lstParseObjects = olstParseObjects;
            if (!interpret())
            {
                nextChain.sendtoChain(lstParseObjects);
            }
        }

        public ChainNode getChainNode()
        {
            return nextChain;
        }

        
    }
}
